//
//  STSpaceSubDetailInfoView.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/9.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "STSpaceSubDetailInfoView.h"

@interface STSpaceSubDetailInfoView()

/// 模型视图
@property (nonatomic, readonly, strong) STSpaceSubDetailInfoViewModel* viewModel;

//IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* introContentLabel;
@property (weak, nonatomic) IBOutlet UILabel* servContentLabel;
@property (weak, nonatomic) IBOutlet UILabel* contactContentLabel;

@end

@implementation STSpaceSubDetailInfoView

- (void)bindViewModel:(id)viewModel
{
    STSpaceSubDetailInfoViewModel* vm = viewModel;
    
    if (!self.viewModel)
    {
        _viewModel = vm;
        
        [self _setup];
    }
    else
    {
    }
}

- (void)_setup
{
    @weakify(self)
    
//    NSMutableAttributedString * attrStr_intro = [[NSMutableAttributedString alloc] initWithData:[self.viewModel.introContent dataUsingEncoding: NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    NSString* strDecode = [NSString htmlEntityDecode:self.viewModel.introContent];
    strDecode = [NSString filterHTML:strDecode];
    NSAttributedString *attrStr_intro = [NSString attributedStringWithHTMLString:strDecode];
    
    NSMutableAttributedString * attrStr_serv = [[NSMutableAttributedString alloc] initWithData:[self.viewModel.servContent dataUsingEncoding: NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    NSMutableAttributedString * attrStr_contact = [[NSMutableAttributedString alloc] initWithData:[self.viewModel.contactContent dataUsingEncoding: NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    
    self.introContentLabel.attributedText = attrStr_intro;
    self.servContentLabel.attributedText = attrStr_serv;
    self.contactContentLabel.attributedText = attrStr_contact;
}

#pragma mark -- 跳转

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
